Converting
Mapping Modes
In Windows,
mapping modes define how numbers relating to object sizes are to be passed and
interpreted. The 32-bit version of OLE uses only one mapping mode, MM_HIMETRIC.
The other Win32 mapping modes include MM_HIENGLISH, MM_LOENGLISH, MM_LOMETRIC,
TWIPS, and PIXEL Modes (MM_ISOTROPIC and MM_ANISOTROPIC being PIXEL modes).
When working with the visual presentation of OLE data, it is important to be
aware of the mapping mode that OLE uses and how this mapping mode affects an
application.
The mapping
modes communicate physical sizes. For example, if an application using
MM_HIMETRIC is to display a line ten centimeters long, the number of units
would be 10,000. However, the line drawn on the screen would be ten centimeters
long, regardless of the size of the video display area. The printed output
would also be a line ten centimeters long.
Note For those
applications that use a mapping mode other than MM_HIMETRIC, the sample user
interface library provides some functions that can be used to convert objects
to and from MM_HIMETRIC units.
Because
people read display screens from a greater distance than they do printed copy,
most applications written for Windows display text in a larger size than they
print it, using what is commonly referred to as logical resolution. For
example, a ten-point font is easy enough to read on the printed page, but
generally appears too small on a screen for comfortable reading. To afford more
comfortable viewing, applications typically expand the size of the displayed
text to some logical size. Using this approach, a column of text that is
physically six inches wide might be eight inches wide on the screen, yet still
print as a six-inch column.
While this
display-enlargement scheme works well from the user s point of view, a problem
can occur when pasting objects into container documents. It is possible to lose
the correct size ratio between the pasted object and the text owned and
displayed by the container. The result is that the container s text is scaled
up for readability but the pasted object might not be. Consequently,
applications must preserve the relative size and position of text and objects,
meaning that if text uses logical resolution, it should scale objects
accordingly.
In the
examples shown in the figure below, a chart object has been pasted from a source
application that uses physical size into documents of two different containers
that use logical resolution for display of the text. The container displaying
the object on the left has scaled up the chart object to the logical size of
the adjacent text to maintain the object/text size ratio. That is, it has been
enlarged from its physical size by an amount that maintains its proportion to
the text of the container document. In the document on the right, the
application displays the chart object at its physical size, with no scaling to
logical resolution for display. Both documents print with the correct
object-to-text-size ratio.
{bmc bm65.WMF}
In OLE, the
units for specifying the size of drawn objects is MM_HIMETRIC, which means
object sizes are in physical units. However, containers need not use the
MM_HIMETRIC mapping mode to draw pasted objects to the display. Rather, they
should should map objects to the screen in the same manner as text. That is, if
the container application displays text to the screen using a mapping mode that
enlarges it, objects should be mapped to the display in the same manner. Using
the same mapping mode for both the text and objects is required to establish
the correct object-to-text ratio as shown in the document on the left side of
the preceding figure. Because most Windows applications use logical resolution
for this type of display mapping, we suggest that OLE containers also use
logical resolution and set up their mapping modes and coordinate transforms
accordingly. This allows objects to be moved from one application to another
without changing their displayed size.